<%@ page import="top.fyxxxx.dbdesign.dao.DBoperate" %>
<%@ page import="top.fyxxxx.dbdesign.util.SysUtil" %>
<%@ page import="top.fyxxxx.dbdesign.data.SignInTask" %>
<%@ page import="top.fyxxxx.dbdesign.util.Reporter" %><%--
  Created by IntelliJ IDEA.
  User: WZL
  Date: 2020/5/4
  Time: 23:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>签到</title>
    <link rel="stylesheet" type="text/css" href="login.css">
</head>
<body >
<%
    if(session.getAttribute("uid")==null)request.getRequestDispatcher("/index.jsp").forward(request,response);
    long uid=(Long)session.getAttribute("uid");
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String ssid=request.getParameter("sid");
    long sid=0;
    if(ssid!=null)sid=Long.parseLong(ssid);
    DBoperate dBoperate=DBoperate.getInstance();
    Reporter reporter=Reporter.getInstance();
    long cid=reporter.getCidBySid(sid);
    String inf[]= reporter.getSignInTaskInformation(sid);
%>

<div id="content">

    <div class="login-header">
        <img src="Image/logo.png">
    </div>
    <p class="mainBody">
        课程：<%=dBoperate.getCourse(cid).getName()%><br>
        发起人:<%=inf[0]%><br>
        开始时间：<%=inf[1]%><br>
        结束时间： <%=inf[2]%>
    </p>
    <form action="SignInServlet" method="post">
        <input type="hidden" name="sid" value="<%=request.getParameter("sid")%>">
        <div class="login-button-box">
            <%
                if(reporter.issignin(uid,sid)){
            %>
            <button    style="background-color: #9e9e9e;border-color: #9e9e9e"  onclick="">已签到</button>
            <%
                }
                else if(!reporter.checkSignTaskTime(sid)){
            %>
            <button    style="background-color: #9e9e9e;border-color: #9e9e9e"  onclick="">不在签到时段内</button>
            <%
                }
                else{
            %>
            <button   type="submit" value="提交">签到</button>
            <%
                }
            %>
        </div>
    </form>
</div>
<div style="text-align: center"><p class="title"><a href="teacherMainPage.jsp">返回首页</a></p></div>
</body>
</html>